package com.xjrsoft.module.ureport.controller;


import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.node.ForestNodeMerger;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.base.vo.ReportInfoManagerVo;
import com.xjrsoft.module.ureport.dto.ReportContentDto;
import com.xjrsoft.module.ureport.dto.ReportInfoDto;
import com.xjrsoft.module.ureport.service.IXjrReportContentService;
import com.xjrsoft.module.ureport.vo.ReportContentOneVo;
import com.xjrsoft.module.ureport.vo.ReportContentVo;
import com.xjrsoft.module.ureport.vo.ReportInfoVo;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwq
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/report-content")
public class XjrReportContentController {

    @Autowired
    private IXjrReportContentService iXjrReportContentService;


    
    @GetMapping
    @ApiOperation("查询所有报表")
    public Response getReportContentAll() {
        return Response.ok(BeanUtil.copyList(iXjrReportContentService.list(), ReportContentVo.class));
    }

    @GetMapping("/{id}")
    @ApiOperation("查询报表详细信息")
    public Response getReportContentById(@PathVariable String id) throws Exception {
        return Response.ok(iXjrReportContentService.getReportContentById(id));
    }

    @PostMapping
    @ApiOperation("新增报表文件")
    public Response saveReportContent(@RequestBody ReportContentDto dto) {
        return Response.status(iXjrReportContentService.saveReportContent(dto));
    }

    @PutMapping("/{id}")
    @ApiOperation("修改报表文件")
    public Response updateRptRelation(@PathVariable String id, @RequestBody ReportContentDto dto) {
        return Response.status(iXjrReportContentService.updateReportContent(id, dto));
    }

    @SneakyThrows
    @DeleteMapping("/{ids}")
    @ApiOperation("删除报表文件")
    public Response deleteRptRelation(@PathVariable String ids) {
        return Response.status(iXjrReportContentService.deleteReportContent(ids));
    }
}
